home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ahoy 1989 February
/
Ahoy_Magazine_89-02_1989_Double_L.d64
/
Monkeys & Coco
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-10-26
|
695b
|
28 lines
1 rem =================================
2 rem
3 rem monkeys & coconuts
4 rem (brute force method)
5 rem
6 rem rupert report #62
7 rem
9 rem =================================
10 def fnii(z)=(z=int(z)) :rem true if z is integer
15 print "[147]": hm $=chr$(19) :rem home
20 for a=1 to 10000
25 print hm$; a;
30 b=(a-1)/5 :rem taken by 1st sailor
35 if not fnii(b) then 100
40 c=(a-b-2)/5 :rem 2nd sailor
45 if not fnii(c) then 100
50 d=(a-b-c-3)/5 :rem 3rd sailor
55 if not fnii(d) then 100
60 e=(a-b-c-d-4)/5 :rem 4th sailor
65 if not fnii(e) then 100
70 f=(a-b-c-d-e-5)/5 :rem 5th sailor
75 if not fnii(f) then 100
80 g=(a-b-c-d-e-f-5)/5 :rem altogether
85 if not fnii(g) then 100
90 print: print "solution: initial # coconuts =";a
100 next a
110 print